from selenium import webdriver
# from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
import time
import random



string=random.randint(1,999)
driver=webdriver.Firefox()
driver.get("http://localhost/agileone")
driver.find_element_by_id("username").send_keys("admin")#输入用户名
ts=driver.find_element_by_id("username").get_attribute("value")#获取输入的用户名
ts1=driver.find_element_by_id("password").get_attribute("id")#获取password的属性id的值
ts2=driver.find_element_by_id("password").get_attribute("class")#获取password的属性class的值
print(ts)
# print(ts1)
# print(ts2)
driver.find_element_by_id("password").send_keys("admin")#输入密码
driver.find_element_by_id("savelogin").is_selected()
driver.find_element_by_id("login").click()#点击登录
time.sleep(3)
driver.find_element_by_partial_link_text("需求提案").click()#点击需求提案
Select(driver.find_element_by_id("type")).select_by_value("Enhancement")#选择类型
time.sleep(2)
Select(driver.find_element_by_id("importance")).select_by_value("High")#选择重要性
time.sleep(2)
driver.find_element_by_id("headline").send_keys(string)#输入标题
driver.find_element_by_css_selector("img.ke-common-icon.ke-icon-source").click()#点击内嵌页面中的代码
driver.find_element_by_class_name("ke-textarea").send_keys("test")#输入需求提案的内容
driver.find_element_by_xpath("//tfoot/tr[1]/td[2]/span/input").click()#点击新增
time.sleep(5)
assert "成功啦: 新增数据成功" in driver.find_element_by_id("msg").text#断言新增成功的消息是否满足预期

driver.switch_to.alert.accept()


# driver.quit()